import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    goods: []
  },
  mutations: {
    getData(state, item) {
      state.goods = [...item]
      console.log(item);
    }
  },
  actions: {
    getData(context) {
      axios.get("http://localhost:8080/shopList.json")
        .then(res => {
          console.log(res.data);
          context.commit('getData', res.data)
        })
    }
  },
  modules: {
  }
})
